/**
 *
 * Copyright 2011 TeleNav, Inc. All rights reserved.
 * GalleryActivity.java
 *
 */
package com.palmwindActivity.Gallery;

import com.palmwindActivity.R;
import com.palmwindActivity.app.AbstractActivity;
import com.palmwindActivity.app.main.MenuHandler;
import com.palmwindActivity.app.main.LocalThumbnailAdapter;
import com.palmwindActivity.thumbnail.ThumbnailActivity;
import com.palmwindActivity.widget.ShellGallery;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.FrameLayout;
import android.widget.Gallery;

/**
 *@author Kane (gongchen.cn@gmail.com)
 *@date 2011-4-6
 */
public class GalleryActivity extends AbstractActivity
{
    private int defaultIndex = 0;
    private LocalThumbnailAdapter thumbnailAdapter;
    
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        this.defaultIndex = this.getIntent().getIntExtra("ViewId", 0);
//        Activity parentActivity = this.getParent();
//        if (parentActivity instanceof ThumbnailActivity)
//        {
//            this.defaultIndex = ((ThumbnailActivity) parentActivity).getViewId();
//            this.thumbnailAdapter = ((ThumbnailActivity) parentActivity).getAdapter();
//        }
        Gallery galleryView = new ShellGallery(this);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
                FrameLayout.LayoutParams.FILL_PARENT);
        galleryView.setLayoutParams(params);
        GalleryAdapter adapter = new GalleryAdapter(this,null/*thumbnailAdapter.getNetBitmaps()*/);
        galleryView.setAdapter(adapter);
        galleryView.setSelection(defaultIndex);
        galleryView.setSpacing(5);
        setContentView(galleryView);
    }
    
   
    
    public boolean onCreateOptionsMenu (Menu menu)
    {
        MenuItem textMenu = menu.add(0, MenuHandler.TEXT_ID, Menu.NONE, R.string.text_input);
        MenuHandler menuHandler = new MenuHandler(this);
        textMenu.setOnMenuItemClickListener(menuHandler);
        return super.onCreateOptionsMenu(menu);
    }

	protected void onStartDelegate() {
		// TODO Auto-generated method stub
		
	}
}
